$(document).ready(function(){	
			$("input").keyup(function(){
				checkNull();
				checkLength(5);
				checkName(0,$("#user").val());
				});
			});
			function checkNull(){
				var help=true;
				input=document.getElementsByTagName("input");
				error=document.getElementsByTagName("p");
				error.innerHTML="";
				for(var i=0;i<input.length-1;i++){
					if(input[i].value=="" || input[i].value==null){
						//error[i].innerHTML="Cannot leave empty";
						showError(i,"cannot leave empty");
						help=false;
						}else{
							error[i].innerHTML="";
							input[i].style.borderColor=""
						}				
					}
					return help;
			}
			function clearForm(){
				input=document.getElementsByTagName("input");
				for(var i=0;i<input.length-1;i++){
					input[i].value="";			
					}
			}
			function showError(id,msg){
				input=document.getElementsByTagName("input");
				error=document.getElementsByTagName("p");
				error[id].innerHTML=msg;
				input[id].style.borderColor="red";
				error[id].style.color="red";
			}
			function validateRegister(){
				var error=true;
					error=checkNull();
					//error=checkLength(5);
					if(error==false){
						error=false;
					}else if(error==true){
						//$( "#error" ).load( "./add_new_author.article" );
						window.location.href= "./add_new_author.article";
						clearForm();
					}
					return false;
			}
			function checkLength(vLength){
			 	var help=true;
				input=document.getElementsByTagName("input");
				for(var i=0;i<input.length-1;i++){
					if(input[i].value.length>vLength){
						showError(i,"maximum length "+vLength+"");
						help=false;
					}
				}
				return help;
			}
			function checkName(id,name){
				if(!isNaN(name.charAt(0)) && name !=""){
					showError(id,"Invalid Username");
				}
			}